package Model;

import java.util.*;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class GameHistory implements IMoveListener {
    private LinkedList<Move> moveList;
    public GameHistory() {
        moveList = new LinkedList<Move>();
    }

    public void movePerformed(Move m) {
        moveList.addLast(m);
    }

    public Move[] undoMoves(int howMany) {
        Move[] movesToBeUndone = new Move[howMany];
        for(int n = 0; n < howMany; n++) {
            movesToBeUndone[n] = moveList.removeLast();
        }
        return movesToBeUndone;
    }

    public void clear() {
        moveList.clear();
    }
}
